package com.codi.bus.core.dao.impl;

import com.codi.base.dao.BaseDAOImpl;
import com.codi.base.dao.plugin.page.PageView;
import com.codi.base.dao.v2.BaseDaoImpl;
import com.codi.base.dao.v2.GeneratedBaseDaoImpl;
import com.codi.bus.core.dao.OrganAgentDao;
import com.codi.bus.core.domain.OrganAgent;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lvgo
 * @version 1.0
 * @Description: 机构经办人
 * @date 2018/5/9 14:30
 */
@Repository("organAgentDao")
public class OrganAgentDaoImpl extends BaseDAOImpl<OrganAgent> implements OrganAgentDao {
    @Override
    public OrganAgent getEntityByMobile(String mobile) {
        return this.getObject(generateStatement("selectOneByMobile"), mobile);
    }

    @Override
    public OrganAgent selectByPrimaryKey(Long agentId) {
        return this.getObject(generateStatement("selectByPrimaryKey"), agentId);
    }

    @Override
    public OrganAgent getEntityByCreateUserId(Long createUserId) {
        return this.getObject(generateStatement("getEntityByCreateUserId"), createUserId);
    }

    @Override
    public void updateByPrimaryKeySelective(OrganAgent organAgent) {
        this.update(generateStatement("updateByPrimaryKeySelective"), organAgent);
    }

    @Override
    public List<OrganAgent> findAll(String profileName,Integer pageIndex, Integer pageSize) {
        Map<String,Object> params = new HashMap<>();
        PageView pageView = getPageView(pageIndex, pageSize);
        params.put("pageView", pageView);
        params.put("profileName",profileName);
        return this.getSqlSession().selectList(generateStatement("findAll"),params);
    }

    @Override
    public int insertOne(OrganAgent organAgent) {
        return this.insert(generateStatement("insertSelective"), organAgent);
    }
}
